package org.dromara.patrol.domain.model;

import jakarta.validation.constraints.*;
import lombok.Data;
import org.dromara.common.core.enums.patrol.RepeatType;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * 执行规则
 */
@Data
public class ExecuteRule implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
     * 循环周期类型 NO_REPEAT-不重复，DAILY-每天，WEEKLY-每周，MONTHLY-每月
     * @see org.dromara.common.core.enums.patrol.RepeatType
     */
    @NotNull(message = "循环周期类型不能为空", groups = { AddGroup.class, EditGroup.class })
    private RepeatType cycleType;
    /**
     * 周规则 1-7 代表周日-周六
     */
    private List<Integer> weeklyRule;
    /**
     * 月规则 1-31 代表每月1号到31号
     */
    private List<Integer> monthlyRule;
    /**
     * 执行日期开始
     */
    @Pattern(regexp="^\\d{4}-\\d{2}-\\d{2}$", message="日期格式必须为yyyy-MM-dd", groups = { AddGroup.class, EditGroup.class })
    private String executeDateStart;
    /**
     * 执行日期结束
     */
    @Pattern(regexp="^\\d{4}-\\d{2}-\\d{2}$", message="日期格式必须为yyyy-MM-dd", groups = { AddGroup.class, EditGroup.class })
    private String executeDateEnd;
    /**
     * 执行时间开始
     */
    @Pattern(regexp="([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]", message="时间格式必须为HH:mm:ss", groups = { AddGroup.class, EditGroup.class })
    private String executeTimeStart;
    /**
     * 执行时间结束
     */
    @Pattern(regexp="([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]", message="时间格式必须为HH:mm:ss", groups = { AddGroup.class, EditGroup.class })
    private String executeTimeEnd;
}
